#ifndef _LAYOUT_WIFI_SETTING_H
#define _LAYOUT_WIFI_SETTING_H

#include <gdk/gdkkeysyms.h>
#include <string.h>

static int wifiset_focus_id=0;

/************wifi struct ******************/

#define INTERFACE_COUNT		16
#define USER_CELL_COUNT		64
#define CELL_COUNT				128
#define NETWORK_SETUP_SCRIPT    "/etc/init.d/Snetwork"
#define NETWORK_CONFIG          "/etc/network/network.conf"


typedef enum _WIFI_STATUS
{
  WIFI_STATIC,
  WIFI_DHCP,
  WIFI_COMFIRM
}WIFI_STATUS;


typedef enum _Wifi_Selete_Stat
{
  WIFI_ICON_SELETE,
  WIFI_WIDGET_SELETE
}Wifi_Selete_Stat;

typedef enum _WIFI_STATS
{
	NONE ,
	WIFI_LIST ,
	WIFI_NET_ADDRESS ,
	WIFI_PASSWD
}WIFI_STATS;

typedef enum _t_encmode
{
  		ENC_OFF = 0x00,
    ENC_OPEN,
    ENC_RESTRICTED
} t_encmode;

typedef enum _t_wifimode
{
  MODE_MANAGED = 0x00,
    MODE_ADHOC
} t_wifimode;

typedef struct _iw_statics
{
  int status;
    int quality;
    int level;
    int noise;
}iw_statics;

typedef struct _WIFI_CELL
{
  char address[32];
    char essid[128];
    char mode[16];
    t_encmode encmode;
    char channel[40];       
    char key[4];
    char userkey[128];
    char surpport_rates[128];
    char bit_rates[8];
    char quality[16];
    char signal_level[16];
    char noise_level[16];
    char state[128];
    char alias[128];
    int linkstate;
    
    //wpa variable
    unsigned int key_mgmt;
    
    //device type
    char device_type[16];
    
    //encryption type
    char encryption_type[16];
    
    unsigned int key_index;
}WIFI_CELL;

typedef struct _WIFI_INTERFACE
{
  char name[16];
    char type[16];
    char essid[128];
    
    char encryption_type[16];
    
    t_wifimode mode;
    t_encmode encmode;
    char channel[4];
    char key[32];
    char quality[8];
    char key1[128];
    
    char address[32];
    char netmask[32];
    char broadcast[32];
    char gateway[32];
    
    gchar *nameserver[2];
    gboolean isdhcp;
    gboolean isstatic;
    /*for statistics data */
    gboolean UP;
    gboolean RUNNING;
    gboolean auto_dns;
    
    gboolean auto_active;  //add by shuai
  
    iw_statics stats;
    gboolean wifi_group_enable;
    WIFI_CELL wifi_group;
}WIFI_INTERFACE;

typedef struct _MY_WIFI
{
  	int interface_index;
    int interface_count;
    WIFI_INTERFACE *wifi_interface[INTERFACE_COUNT];
    int cell_index;
    int cell_count;
    int user_cell_count;
    int user_cell_index;
    WIFI_CELL *wifi_cell[CELL_COUNT];
    WIFI_CELL *user_wifi_cell[USER_CELL_COUNT];
    
    GtkWidget* wifi_view;
    GtkWidget* wifi_combo;
    int cell_type;
}MY_WIFI;

typedef struct	_NetWorkWifi
{
  		MY_WIFI *my_wifi;
    char Link_AP_MAC[48];
    GtkWidget *global_build_list;
    GtkWidget *mainwindow;
    GtkWidget *connect_window;
    GtkWidget *static_window;
    GtkTooltips *tooltips;
    gint connect_index;
    gint user_wifi_count;
    gboolean linkconnect;//if link layer is connect
  		gchar *sel_key;
    int  key_mgmt;
    int key_index;
    gchar *type;
    gboolean RUNNING;
}NetWorkWifi;


/*************wifi struct*******************/

typedef struct _Icon_Wifi
{
  char *name;
    
    //LAN_SETTING_ICON_TYPE type;
    
    GooCanvasItem *icon;
    GooCanvasItem *icon_a;
    
    LAYOUT_WIN_ID id;
    
    char *cmd;
    char **argv;
    int argc;
    
    int x;
    int y;
    int size;
    int asize;
}Icon_Wifi;


typedef struct _BackGround_Wifi
{
  GooCanvasItem *bg;
    GooCanvasItem *label ;
    GooCanvasItem *pic1 ;
    GooCanvasItem *pic2 ;
    GdkPixbuf*  pixbuf1;
    GdkPixbuf*  pixbuf2;
    int bg_x1 ;
    int bg_y1 ;
    int bg_w1 ;
    int bg_h1 ;
    int bg_x2 ;
    int bg_y2 ;
    int bg_w2 ;
    int bg_h2 ;
}BackGround_Wifi;


typedef struct _Entry_Wifi
{
  		GooCanvasItem *text ;
    GtkWidget *entry_wifi ;
    char *name ;
    char *tooltips ;
    char *font ;
    int entry_x ;
    int entry_y ;
    int text_x ;
    int text_y ;
    
    struct _Entry_Wifi *next ;
    struct _Entry_Wifi *prv ;
}Entry_Wifi;



typedef struct _WifiLayout
{
	GooCanvasItem *tree_list ;
	GtkWidget *list ;
	GtkWidget *connect_window ;
  int micon_count;
  int entry_count ;
  int focus_id ;
  Icon_Wifi icons[3];
    Exec *exec;

  Layout *layout ;
    char buf[512] ;

		WIFI_STATUS wifi_stats ;
			Wifi_Selete_Stat wifi_selete ;
    WIFI_STATS wifistas ;
    Entry_Wifi *entrys_net ;
    Entry_Wifi *entrys_passwd ;
    BackGround_Wifi *bg_wifi ;
    
    NetWorkWifi *wifi ;
}WifiLayout;

void hide_list(Layout *layout);
static void set_title_label(gchar *text, Layout *layout);
static void get_ap_mac(Layout *layout);
static void get_interface_statistics_data(WIFI_INTERFACE *iface);
static void review_tree_vanpro(char *data, Layout *layout);
void show_wifi_net_address(Layout *layout);

#endif
